package view;


import model.Login;

import javax.swing.*;
import java.awt.event.ActionEvent;

public class LoginView extends JPanel implements ActionListener {
    Login login;
    JTextField inputID;
    JPasswordField inputPassword;
    JButton buttonLogin;
    boolean loginSuccess;
    public LoginView(){
        login=new Login();
        inputID=new JTextField(12);
        inputPassword=new JPasswordField(12);
        buttonLogin=new JButton("登录");
        add(new JLabel("ID:"));
        add(inputID);
        add(new JLabel("密码:"));
        add(inputPassword);
        add(buttonLogin);
        buttonLogin.addActionListener();
    }
    public boolean isLoginSuccess(){
        return loginSuccess;
    }
    public void actionPerformed(ActionEvent e){
        login.setId(inputID.getText());
        char[] pw=inputPassword.getPassword();
        login.setPassword(new String(pw));
        loginSuccess=login.isLoginSuccess();
    }

}
